<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
var upload = 'http://'+window.location.hostname+':'+window.location.port;
var defaultImg = "static/img/defaultImg/defaultLongImg.png";
var firstImg="";
var dialog_a; 
//初始化
$(function() {
	if(sys_turningimagsId!=null && sys_turningimagsId!=0){
			$.ajax({
		    	async: false,
		    	url : global_param.context_name + '/system/selectTurningimagInfo.do', 
				type : 'post', 
				data : {
					"id" : sys_turningimagsId
					},
				success: function(data){
					firstImg=data.turningimags_path;
					$('#turningimags_id').val(data.id);
					$('#turningimags_title2').val(data.turningimags_title);
					$('#enable_flag2').val(data.enable_flag);
					$('#sort_order2').val(data.sort_order);
					$('#sys_img_path').val(data.turningimags_path);
					$("#bigImageParent").attr("src",global_param.context_name+data.turningimags_path);
				}  
		  	});
	}else{
		$('#bigImageParent').attr("src",defaultImg);
	}
});
function shangchuan(){
	   BootstrapDialog.show({
		title: '上传轮播图片',
		titleClass: 'text-center',
		size:BootstrapDialog.SIZE_MIDDLE,
	    message: $('<div style="min-height: 450px;"></div>').load('static/html/systemManage/addImgs.html'),
	    buttons: [{
	        label: '保存',
	        cssClass:'btn btn-primary col-sm-1 col-sm-offset-4 col-xs-4 col-xs-offset-3',
	        action: function(dialog) {
	        	dialog_a = dialog;
	        	addImgs();
        		//dialog.close();
	    	}
	    }, {
	        label: '关闭',
	        cssClass:'btn btn-default col-sm-1 col-sm-offset-4 col-xs-4 col-xs-offset-3',
	        action: function(dialog) {
	            dialog.close();
	        }
	    }]
	});
}



function deleteImg1(){
	//删除当前页面图片
	if($('#bigImageParent').attr('src')==defaultImg){
		return;
	}
	if(flagForUpdate==1){
		//修改时删除
		$('#bigImageParent').attr('src', defaultImg);
	    $('#sys_img_path').val('');
	    toastr.success("操作成功");
	}else{
		//新增时删除
		  $.ajax({
		        type: "POST",
		        url: global_param.context_name + "/personnelManage/deleteImg.do",
		        data:{
		            "oldFileName": $('#sys_img_path').val(),
		            "defaultImg":defaultImg
		        },
		        async: false,
		        success: function(json) {
		        	if(json=="success"){
		        		toastr.success("操作成功");
		        		$('#bigImageParent').attr('src',defaultImg);
		        	    $('#sys_img_path').val('');
		        	}
		        	
		        }
		    }); 
		}
	}
	
	
	function deleteForClose(){
		 $.ajax({
		        type: "POST",
		        url: global_param.context_name + "/personnelManage/deleteImg.do",
		        data:{
		            "oldFileName": $('#sys_img_path').val(),
		            "defaultImg":defaultImg,
		            "firstImg":firstImg
		        },
		        async: false,
		        success: function(json) {
		        	
		        }
		    }); 
	}
</script>
</head>
<body>
	<form id="add_dict_form" method="post" >
	<div class="form-group col-sm-12"></div>
	<div class="form-group col-sm-12"></div>
	<div class="form-group col-sm-12"></div>
	    <div class="form-group col-sm-12">
	    <input id="turningimags_id" type="hidden" name="turningimags_id" />
	    	<div class="form-group col-sm-1" style="text-align: right">
	        	<label for="turningimags_title2"><span class="text-red">*</span>标题</label>
	        </div>
	        <div class="form-group col-sm-6" style="margin-left:-20px;">
	        	<input class="form-control" id="turningimags_title2" name="turningimags_title2"  maxlength="20" placeholder="请输入少于20个汉字"/>
	    	</div>
	    </div>	
	    <div class="form-group col-sm-12">
	    	<div class="form-group col-sm-1" style="text-align: right">
	        	<label for="enable_flag2" style="text-align: right">启用状态</label>
	        </div>
	        <div class="form-group col-sm-1" style="margin-left:-20px;">
	        	<select class='form-control' id='enable_flag2' name='enable_flag2'>
	                <option value='1' selected='true'>启用</option>
	                <option value='0'>禁用 </option>
			 	</select>
			 </div>
	    </div>
	    <div class="form-group col-sm-12">
	    	<div class="form-group col-sm-1" style="text-align: right">
	        	<label for="sort_order2">排序</label>
	        </div>
	        <div class="form-group col-sm-1" style="margin-left:-20px;">
	        	<input class="form-control" id="sort_order2" name="sort_order2" value="0" onkeyup="value=value.replace(/[^\d]/g,'')"></input>
	        </div>
	    </div>
	    
	    <div class="form-group col-sm-12">
		    <div class="form-group col-sm-1" style="text-align: right">
		        <label for=""><span class="text-red">*</span>图片</label>
		     </div>
	        <div class="form-group col-sm-10" style="margin-left:-20px;">
		        <!-- 图片信息Tab --> 
		    <div >
			    <div style="width:650px;height:347px; border: 1px solid gray" >
				    <img id="bigImageParent" class="double-border" src=""   alt="" width=648px  height="345px" />
				    <input id="sys_img_path" name="sys_img_path" type="hidden"/> 
			    </div> 
		    </div>
		    <div style="margin-top:-35px;margin-left:680px;">
			    <input type="button" onclick="shangchuan()" value="上传" class="btn btn-primary" id="addBu"></input> 
			    <input type="button" onclick="deleteImg1()" value="删除" class="btn btn-default" id="deleteBu"></input>
	     	</div>
	     	</div>
    	</div> 
<!--     	<div class="form-group col-sm-12"> -->
<!--     	<div class="form-group col-sm-3"></div> -->
<!--     	<div class="form-group col-sm-5" style="margin-left:-60px;"><strong>建议图片大小为：QQQ*XXX</strong></div> -->
<!--     	</div> -->
	</form>
</body>
</html>